package cn.hr.service.impl;

import cn.hr.dao.mapper.MissionTypeMapper;
import cn.hr.pojo.MissionType;
import cn.hr.service.MissionTypeService;
import cn.hr.utils.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@CacheConfig(cacheNames = "mission")
@Scope("prototype")
@Service("missionTypeService")
public class MissionTypeServiceImpl implements MissionTypeService {

    @Resource
    private MissionTypeMapper missionTypeMapper;

    @Override
    public boolean insert(MissionType missionType) throws Exception {
        return missionTypeMapper.insert(missionType)>0;
    }

    @Override
    public boolean update(MissionType missionType) throws Exception {
        return false;
    }

    @Override
    public boolean delete(Integer id) throws Exception {
        return missionTypeMapper.delete(id)>0;
    }

    @Override
    public MissionType get(Integer id) throws Exception {
        return missionTypeMapper.get(id);
    }

    @Override
    public PageInfo<Map> findListByCondition(Map m, int pageNo) throws Exception {
        PageHelper.startPage(pageNo,Constants.PAGESIZE);
        List<Map> list = missionTypeMapper.findListByCondition(m);
        PageInfo<Map> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Long findCountByCondition(Map m) throws Exception {
        return null;
    }
}
